package com.muxue.module.ai.controller.chat;


import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Tag(name = "管理后台 - AI 聊天对话")
@RestController
@RequestMapping("/ai/chat/conversation")
@Validated
public class AiChatConversationController {

//    @Resource
//    private AiChatConversationService chatConversationService;
//    @Resource
//    private AiChatMessageService chatMessageService;
//
//    @PostMapping("/create-my")
//    @Operation(summary = "创建【我的】聊天对话")
//    public CommonResult<Long> createChatConversationMy(@RequestBody @Valid AiChatConversationCreateMyReqVO createReqVO) {
//        return success(chatConversationService.createChatConversationMy(createReqVO, getUserId()));
//    }
//
//    @PutMapping("/update-my")
//    @Operation(summary = "更新【我的】聊天对话")
//    public CommonResult<Boolean> updateChatConversationMy(@RequestBody @Valid AiChatConversationUpdateMyReqVO updateReqVO) {
//        chatConversationService.updateChatConversationMy(updateReqVO, getUserId());
//        return success(true);
//    }
//
//    @GetMapping("/my-list")
//    @Operation(summary = "获得【我的】聊天对话列表")
//    public CommonResult<List<AiChatConversationRespVO>> getChatConversationMyList() {
//        List<AiChatConversationDO> list = chatConversationService.getChatConversationListByUserId(getUserId());
//        return success(BeanUtils.toBean(list, AiChatConversationRespVO.class));
//    }
//
//    @GetMapping("/get-my")
//    @Operation(summary = "获得【我的】聊天对话")
//    @Parameter(name = "id", required = true, description = "对话编号", example = "1024")
//    public CommonResult<AiChatConversationRespVO> getChatConversationMy(@RequestParam("id") Long id) {
//        AiChatConversationDO conversation = chatConversationService.getChatConversation(id);
//        if (conversation != null && ObjUtil.notEqual(conversation.getUserId(), getUserId())) {
//            conversation = null;
//        }
//        return success(BeanUtils.toBean(conversation, AiChatConversationRespVO.class));
//    }
//
//    @DeleteMapping("/delete-my")
//    @Operation(summary = "删除聊天对话")
//    @Parameter(name = "id", required = true, description = "对话编号", example = "1024")
//    public CommonResult<Boolean> deleteChatConversationMy(@RequestParam("id") Long id) {
//        chatConversationService.deleteChatConversationMy(id, getUserId());
//        return success(true);
//    }
//
//    @DeleteMapping("/delete-by-unpinned")
//    @Operation(summary = "删除未置顶的聊天对话")
//    public CommonResult<Boolean> deleteChatConversationMyByUnpinned() {
//        chatConversationService.deleteChatConversationMyByUnpinned(getUserId());
//        return success(true);
//    }
//
//    // ========== 对话管理 ==========
//
//    @GetMapping("/page")
//    @Operation(summary = "获得对话分页", description = "用于【对话管理】菜单")
//    @PreAuthorize("@ss.hasPermission('ai:chat-conversation:query')")
//    public CommonResult<PageResult<AiChatConversationRespVO>> getChatConversationPage(AiChatConversationPageReqVO pageReqVO) {
//        PageResult<AiChatConversationDO> PageResult = chatConversationService.getChatConversationPage(pageReqVO);
//        if (CollUtil.isEmpty(PageResult.getList())) {
//            return success(PageResult.empty());
//        }
//        // 拼接关联数据
//        Map<Long, Integer> messageCountMap = chatMessageService.getChatMessageCountMap(
//                convertList(PageResult.getList(), AiChatConversationDO::getId));
//        return success(BeanUtils.toBean(PageResult, AiChatConversationRespVO.class,
//                conversation -> conversation.setMessageCount(messageCountMap.getOrDefault(conversation.getId(), 0))));
//    }
//
//    @Operation(summary = "管理员删除对话")
//    @DeleteMapping("/delete-by-admin")
//    @Parameter(name = "id", required = true, description = "对话编号", example = "1024")
//    @PreAuthorize("@ss.hasPermission('ai:chat-conversation:delete')")
//    public CommonResult<Boolean> deleteChatConversationByAdmin(@RequestParam("id") Long id) {
//        chatConversationService.deleteChatConversationByAdmin(id);
//        return success(true);
//    }

}
